home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
HARDWARE
/
IICALARM
/
!iicAlarm
/
Tools
/
!AlarmShut
/
!Runimage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1994-05-04
|
8KB
|
253 lines
> iicAlarmShutdown 0.50
This program shuts down the computer and switches it off.
This program was developed from !Shutdown by Stuart Hickinbottom,
thanks for the idea.
Version 0.30
It sends a <Shift-Control_F12> to the wimp and waits for the applikations
to close down. It shows a window and sets the Aux-lines to switch off
the computer.
Version 0.40
New in RiscOs 3.xx. It sends a Shutdown-Command to the TaskManager.
ESCAPE key functions as an abort key.
Version 0.50
removed all RiscOs2 stuff.
+10000
ON ERROR PROCerrorReport(REPORT$,FALSE)
"Error in Shutdown: ";
$" in "
"<AlarmShut$Dir>.^.^.SwitchOff"
Dapname$ = "iicAlarmShutdown" :
Name in Taskmanager-Window
buff% 1024 :
Buffer for window & Template
spritelen% = 10*1024
spritebuf% spritelen% :
Buffer for Sprites
indlen% = 100
indbuf% indlen% :
Buffer for indirected Data
ptr% = indbuf%
status% = 0
Bf% = 7 :
Iconno. in Templatefile.
If we are in command-mode/non-desktop. We can simply call the
switch-off function.
We check it by the number of existing applications.
"Wimp_ReadSysInfo", 0
tasknum%
tasknum%<2
switchoff
Otherwise. We use a Task-program to control the shutdown procedure
of the applications.
BUT we can still be in a command-line, eg. F12-mode or task-window.
Meaning, that we have to start from within a task...
This doesn't work with Wimp_Initialise because the current task refuses
to die. Problem.. a new task can only start a *command...
Since we are run only under the desktop, we are always started via
Filer_Run or StartTask... or so.
4EAuxSet =
initSwitchOffRoutine :
Routine to set Aux1/2-lines.
67taskhdl%=
initTask(apname$) :
Enter the Wimp
getTemplate :
Load our window
loadSprites
From now on we don't need to load anything else.
displayWindow(
Now in RiscOS 3, we have a command for the taskmanager itself.
We tell him to shutdown without the dialogue box.
"TaskManager_Shutdown", %00001
@!mask% = %11100001100000110000
status% = 2
errorReport(
Wir koennen noch nicht herausfinden, ob jemand abbrechen wollte und
haben deshalb nur ein Timeout von 30 Sekunden.
tm% =
+ 3000
wimpPoll
wimpPoll
O%
"Wimp_Poll",mask%,buff%
0 :
NULLevent
R.
2 :
"Wimp_OpenWindow",,buff%
S:
6 :
checkMouse(buff%!8,buff%!12,buff%!16)
T8
8 :
checkKeys(buff%!0,buff%!4,buff%!24)
; Nullevents bearbeiten
[L; Unser Rechner hat also genug Zeit, um sich mit sowas zu beschaeftigen.
NULLevent
])
"Wimp_ReadSysInfo", 0
tasknum%
tasknum%<2
status%
0,1: status% += 1
a'
2 :
"XOS_CLI","ShutDown"
b$
displayWindow(
status% += 1
3 : tm% =
+ 2000
eI
Shutflag gesetzt. Also alle Tasks weg und alle Files
fK
geschlossen.Jetzt koenen wir die Aux-Leitungen setzen.
g# A% = 3:
AuxSet
status% += 1
i)
"Hourglass_Start", 1
j5
4 :
"Hourglass_Percentage", (tm%-
)/100
; Bearbeite Mouseclicks
pM; Wenn unser Fenster betroffen ist und unser Icon gedrueckt wurde mit der
q?; richtigen Taste dann fuehre den gewuenschten RESET durch.
r6; buttons windowhandle iconhandle
checkMouse(B%,g%,q%)
winhdl%:
v3
2)<>2
doReset
; Bearbeite Tastaturevents
|:; Wenn unser Fenster gemeint ist und
gedrueckt wurde
}F; dann invertieren wir unsere Taste als haetten wir sie gedrueckt.
~%; ansonsten geben wir sie weiter.
5; Wenn ESCAPE gedrueckt wird, beenden wir sofort.
'; windowhandle iconhandle character
checkKeys(g%,q%,r%)
winhdl%:
r%=13
( buff%!0=winhdl%
# buff%!4=f%
& buff%!8=1<<21
' buff%!12=1<<21
5
"Wimp_SetIconState",,buff%
2
checkMouse(1,winhdl%,f%)
s%=
%
r%=27
tm%=
"Wimp_ProcessKey",r%
displayWindow(C%)
h%,i%
Fenster auf dem Bildschirm zentrieren.
getScreensize
buff%!0 = winhdl%
"Wimp_GetWindowState",,buff%
h% = buff%!12 - buff%!4
i% = buff%!16 - buff%!8
buff%!4 = j%/2 - h%/2
buff%!8 = k%/2 - i%/2
buff%!4=-32000:buff%!8=-32000
buff%!12=buff%!4+h%
buff%!16=buff%!8+i%
Fenster anzeigen
"Wimp_OpenWindow",,buff%
Cursor in unser Fenster, aber unsichtbar !!
"Wimp_SetCaretPosition",winhdl%,-1,0,0,1<<25,0
&; Berechne Bildgroesse in OSunits.
getScreensize
u%,v%
"OS_ReadModeVariable",
,,u%
"OS_ReadModeVariable",
,,v%
"OS_ReadModeVariable",
,,j%
"OS_ReadModeVariable",
,,k%
" j%=(j%+1)<<u%:k%=(k%+1)<<v%
doReset
t% 50
P%=t%
[ OPT0
MOV R0,#200
1 MOV R1,#3 ; Escape aus
D MOV R2,#0 ; Reset ergibt nun einen echten
1 SWI "XOS_Byte" ; Kaltstart.
MOV R0,#&3800000
LDR R1,[R0]
STR R1,[R1,-1]
H SWI "XOS_EnterOS" ; Reset nur im Supervisor moeglich.
MOV R0,R0
8 MOV PC,#0 ; Reset-Ansprung !!
tm%=
.; Anzeigen eines Errors in einer Errorbox.
3; Je nach Typ werden verchiedene Boxen gezeigt.
2; Wird CANCEL gewaehlt, wird abnormal beendet.
errorReport(a$,D%)
Cancel Drag-Operations
"Wimp_DragBox",,-1
O
<>2001
a$+=" (internal error code "+
+"). Do you wish to quit?"
a$+=
d%=1-2*(
<>2001)
d%=2
!buff%=
$(buff%+4)=a$
"Wimp_ReportError",buff%,d%,apname$
(d%=1
<>2001)
initTask(c$)
w%,x%
"Wimp_Initialise",200,&4B534154,c$
w%,x%
w%<200
0,"WIMP is too old to initialise '"+c$+"'."
getTemplate
"Wimp_OpenTemplate",,"<AlarmShut$Dir>.Templates"
4 winhdl% =
loadWindow("AlarmShut",spritebuf%)
"Wimp_CloseTemplate"
loadWindow(tplname$,sprbuf%)
Wir laden das erste Window in den Speicher.
"Wimp_LoadTemplate",,buff%,ptr%,indbuf%+indlen%,-1,
tplname$+
0)),0
,,ptr%
buff%!64=sprbuf%
Wir uebergeben das Fenster ans WIMP.
Damit koennen wir unsere Daten vergessen.
"Wimp_CreateWindow",,buff%
loadSprites
Sprite-Bereich vorbereiten
spritebuf%!0=spritelen%
spritebuf%!4=0
spritebuf%!8=16
spritebuf%!12=16
Sprite laden in privaten Pool
"OS_SpriteOp",266,spritebuf%,"<AlarmShut$Dir>.Sprites"
); End-routine for normal termination.
+; End-routine for abnormal termination.
A% = 0:
AuxSet
"Hourglass_Off"
"Wimp_CloseDown",taskhdl%,&4B534154